package com.xfcy.blog.controller.web;

import com.xfcy.blog.annotation.BusinessLogger;
import com.xfcy.blog.common.R;
import com.xfcy.blog.dto.FriendLinkDTO;
import com.xfcy.blog.service.FriendLinkService;
import com.xfcy.blog.valid.AddGroup;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 晓风残月Lx
 * @date 2023/4/18 19:52
 */
@RestController
@RequestMapping("/web/friend")
@Api(tags = "友链接口")
public class WebFriendLinkController {

    @Autowired
    private FriendLinkService friendLinkService;

    @BusinessLogger(value = "友链模块-友链列表", type = "查询", desc = "友链列表")
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @ApiOperation(value = "友链模块-友链列表", httpMethod = "POST", response = R.class, notes = "友链列表")
    public R webFriendLinkList(){
        return friendLinkService.webFriendLinkList();
    }

    @BusinessLogger(value = "友链模块-申请友链", type = "添加", desc = "申请友链")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ApiOperation(value = "友链模块-申请友链", httpMethod = "POST", response = R.class, notes = "申请友链")
    public R addFriendLinkList(@Validated(AddGroup.class) @RequestBody FriendLinkDTO friendLinkDTO) {
        return friendLinkService.applyFriendLink(friendLinkDTO);
    }


}
